package com.enzoism.spring.entity;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @program: Java_Spring01
 * @description: 对象后置处理器
 * @author: zhifeng
 * @create: 2020-12-22 12:54
 */
@Component
public class BeanHandler implements BeanPostProcessor {
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof User){
            System.out.println("--------【处理器】初始化前--------");
        }
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof User){
            System.out.println("--------【处理器】初始化后--------");
        }
        return bean;
    }
}